home *** CD-ROM | disk | FTP | other *** search
- property spriteNum, pDart, pLoc, pDistanceFromBoard, pBoardHeightFromGround, pPower, pDeterMinePower, pGravity, pair, pDiffer, pScale, pHeightOfDart, pOgHeight, pOgWidth, pFollow, hateV, hateH, myOloc, myOh, myOv, myOr
- global gDartCount, gEnableGrab, gEnablethrow, gIB, gBscreen, gDartPoint, gTargets, gRound, gCRBox, gDartButtons, gCurrentScore, gRoundScore, gCSBox, gRSBox, gDartScore, gTargetsBlocked, gDartList, gCompDart
-
- on beginSprite me
- gDartList.add(spriteNum)
- myOloc = sprite(spriteNum).loc
- myOh = sprite(spriteNum).height
- myOv = sprite(spriteNum).width
- myOr = sprite(spriteNum).rotation
- end
-
- on cleanUp me
- sprite(spriteNum).loc = myOloc
- sprite(spriteNum).height = myOh
- sprite(spriteNum).width = myOv
- sprite(spriteNum).rotation = myOr
- end
-
- on init me
- pDart = sprite(spriteNum)
- pDistanceFromBoard = 96
- pBoardHeightFromGround = 68
- pGravity = 0.59999999999999998
- pHeightOfDart = 28
- pOgHeight = pDart.height
- pOgWidth = pDart.width
- pFollow = timeout("follow").new(1, #followMouse, me)
- pair = VOID
- end
-
- on followMouse me
- if (the mouseH >= 0) and (the mouseH <= (the stage).rect.width) and ((the mouseV >= 250) and (the mouseV <= (the stage).rect.height)) then
- pDart.loc = the mouseLoc
- else
- pDart.locH = the mouseH
- end if
- end
-
- on mouseDown me
- if voidp(pair) and (pDistanceFromBoard > 0) then
- gEnablethrow = 1
- pFollow.forget()
- pLoc = []
- pLoc[1] = pDart.locH
- pLoc[2] = pDart.locV
- pDistanceFromBoard = 96
- pHeightOfDart = 28
- pDeterMinePower = timeout("power" & string(spriteNum)).new(5, #buildPower, me)
- end if
- end
-
- on mouseUp me
- if gEnablethrow and (pDistanceFromBoard > 0) then
- puppetSound(4, member("throw dart"))
- gEnablethrow = 0
- hateH = the mouseH
- hateV = the mouseV
- pDartsCount = pDartsCount + 1
- pDeterMinePower.forget()
- buildPower()
- pair = timeout("pAir" & string(spriteNum)).new(5, #thrown, me)
- end if
- end
-
- on mouseUpOutSide me
- if gEnablethrow and (pDistanceFromBoard > 0) then
- puppetSound(4, member("throw dart"))
- gEnablethrow = 0
- hateH = the mouseH
- hateV = the mouseV
- pDartsCount = pDartsCount + 1
- pDeterMinePower.forget()
- buildPower()
- pair = timeout("pAir" & string(spriteNum)).new(10, #thrown, me)
- end if
- end
-
- on buildPower me
- pPower = -((float(hateV) - pLoc[2]) * 0.17999999999999999) * 0.72999999999999998
- pDiffer = -((float(hateH) - pLoc[1]) * 0.17999999999999999) * 0.72999999999999998
- if pPower < 10 then
- pPower = 10
- end if
- if pPower > 22 then
- pPower = 22
- end if
- end
-
- on thrown me
- pDart.height = pDart.height - 3.54000000000000004
- pDart.width = pDart.width - 3.54000000000000004
- pDart.rotation = pDart.rotation + (pPower * 1.30000000000000004)
- pPower = pPower - pGravity
- pDistanceFromBoard = float(pDistanceFromBoard) - 2.5
- pHeightOfDart = pHeightOfDart + pPower
- pLoc[2] = pLoc[2] - pPower
- pLoc[1] = pLoc[1] - pDiffer
- pDart.locV = pLoc[2]
- pDart.locH = pLoc[1]
- pLoc[2] = pDart.locV
- pLoc[1] = pDart.locH
- if pDistanceFromBoard <= 0 then
- if pDart.locV < 440 then
- og = [290.0, 220.0]
- pd = [pDart.locH.float, pDart.locV.float]
- vec = [pd[1] - og[1], pd[2] - og[2]]
- veclen = sqrt((vec[1] * vec[1]) + (vec[2] * vec[2]))
- if veclen > 190 then
- puppetSound(4, member("dart hit"))
- else
- puppetSound(4, member("dart hit 2"))
- end if
- else
- puppetSound(4, member("hit floor"))
- end if
- pair.forget()
- gDartPoint.loc = pDart.loc
- repeat with i = 1 to gTargets.count
- updateStage()
- if gDartPoint.intersects(gTargets[i]) then
- gCurrentScore = gCurrentScore + sprite(gTargets[i]).returnPoints()
- gCSBox.text = string(gCurrentScore)
- gDartScore[gDartCount] = string(sprite(gTargets[i]).returnPoints())
- end if
- end repeat
- member("dart" && string(gDartCount)).text = string(gDartScore[gDartCount])
- gEnableGrab = 1
- if gDartCount = 3 then
- gBscreen = timeout("bscreen").new(800, #bscreen, me)
- end if
- end if
- end
-
- on bscreen me
- gBscreen.forget()
- whoDart = 1
- repeat with i = 1 to 3
- the randomSeed = the ticks
- if gTargets.count > 0 then
- hate = 1
- repeat while hate
- hi = gTargets[random(gTargets.count)]
- if not gTargetsBlocked.findPos(hi) then
- hate = 0
- puppetSound(6, member("throw dart"))
- gCompDart[whoDart].throw(hi)
- whoDart = whoDart + 1
- gTargetsBlocked.add(hi)
- sprite(hi).blend = 50
- sprite(hi).color = rgb(0, 200, 100)
- gTargets.deleteOne(hi)
- updateStage()
- end if
- end repeat
- end if
- end repeat
- repeat with u = 1 to gCompDart.count
- gCompDart[u].cleanUp()
- end repeat
- gDartCount = 0
- gRound = gRound + 1
- gDartScore = [0, 0, 0]
- gCRBox.text = string(gRound)
- repeat with i = 1 to 3
- member("dart" && string(i)).text = "0"
- end repeat
- repeat with i = 1 to gDartList.count
- sprite(gDartList[i]).cleanUp()
- end repeat
- repeat with i = 1 to gDartButtons.count
- sprite(gDartButtons[i]).visible = 1
- end repeat
- repeat with i = 1 to gIB.count
- sprite(gIB[i]).cleanUp()
- end repeat
- if gTargets.count = 0 then
- gameEnd()
- end if
- end
-
- on gameEnd me
- go("game over")
- end
-